import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';

/**
 * 订单表
 */
@Entity('biz_order_list', { comment: '订单表' })
export class BizOrderListEntity extends BaseEntity {
  @Index()
  @Column({ comment: '订单编号', length: 100, nullable: false })
  orderNo: string;

  @Column({
    comment:
      '状态 0-已取消 1-已完成 2-定金待支付 3-施工中 4-结算审核中 5-尾款待支付',
    type: 'tinyint',
    default: 0,
  })
  status: number;

  @Column({ comment: '客户id' })
  userId: number;

  @Column({ comment: '所有工种类型 逗号分隔' })
  workTypes: string;
  @Column({ comment: '所有工人id 逗号分隔' })
  workerIds: string;

  @Column({ comment: '工期开始时间', type: 'date' })
  startDate: Date;
  @Column({ comment: '工期结束时间', type: 'date' })
  endDate: Date;

  @Column({
    comment: '定金',
    type: 'decimal',
    precision: 18,
    scale: 2,
    default: 0,
  })
  priceDeposit: number;
  @Column({ comment: '定金支付时间', type: 'datetime', default: null })
  priceDepositPayDate: Date;
  // @Column({
  //   comment: '施工总价 工人上传凭证时填入的自己工时费用',
  //   type: 'decimal',
  //   precision: 18,
  //   scale: 2,
  //   default: null,
  // })
  // priceWorkAll: number;
  @Column({
    comment: '订单施工总价 (包含定金，师傅上传凭证时修改)',
    type: 'decimal',
    precision: 18,
    scale: 2,
    default: null,
  })
  priceAll: number;
  @Column({
    comment: '平台管理费 (订单施工总价 * 3%)',
    type: 'decimal',
    precision: 18,
    scale: 2,
    default: null,
  })
  priceTip: number;
  @Column({
    comment: '师傅收入总额 (订单施工总价 - 平台管理费)',
    type: 'decimal',
    precision: 18,
    scale: 2,
    default: null,
  })
  priceWorkerAll: number;
  @Column({
    comment: '订单尾款 (订单施工总价 - 定金)',
    type: 'decimal',
    precision: 18,
    scale: 2,
    default: null,
  })
  priceAllResidue: number;
  @Column({ comment: '订单尾款支付时间', type: 'datetime', default: null })
  priceAllResiduePayDate: Date;

  @Column({ comment: '备注', default: '' })
  notes: string;
}
